package DControl;
import java.awt.event.MouseEvent;
import java.util.*;
public class DRadioGroup extends DComponent implements DMouseListener{
	ArrayList<DRadio> list = new ArrayList<DRadio>();
	int index = 0;
	DRadio radio;
	
	public DRadioGroup(){}
	
	public void addControl(DRadio control)
	{
		list.add(control);
		control.getGroup(this);
		if(control.isSelect == true)
		{
			index = list.indexOf(control);
		}

	}
	
	public void setRadio(DRadio radio)
	{
		this.radio = radio;
	}
	
	public int getIndex()
	{
		return index;
	}
	 
	 public void mouseEntered(MouseEvent e){}
   	 
	  public void mouseExited(MouseEvent e){}
	   	 
	  public void mousePressed(MouseEvent e)
	  {
		  for(int i = 0; i < list.size(); i++)
		  {
			  if(list.get(i) == radio)
			  {
				  index = i;
			  }
			  else
			  {
				  if(list.get(i).isSelect == true )
				  {
					  list.get(i).setSelect(false);
					  list.get(i).repaint();
				  }

			  }
			  
			  //System.out.println("Index : " + index);
		  }

	  }
	   	 
	  public void mouseReleased(MouseEvent e){}
	   	 
	  public void mouseClicked(MouseEvent e){}

}
